using System;
using DotNetNuke.Common;
using DotNetNuke.Entities.Modules;
using DotNetNuke.Entities.Modules.Actions;
using DotNetNuke.Framework;
using DotNetNuke.Security;
using DotNetNuke.Services.Localization;

namespace ITCrossing
{
	public partial class itcMetaPost_Admin : PortalModuleBase
	{
		protected override void OnInit(EventArgs e)
		{
			base.OnInit(e);
			Load += new EventHandler(Page_Load);
		}

		#region IActionable Members

		public ModuleActionCollection ModuleActions
		{
			get
			{
				//create a new action to add an item, this will be added to the controls
				//dropdown menu
				ModuleActionCollection actions = new ModuleActionCollection();
				actions.Add(GetNextActionID(),
				            Localization.GetString(ModuleActionType.EditContent, LocalResourceFile),
				            ModuleActionType.EditContent, "", "", Globals.NavigateURL("Settings_PE"), false,
				            SecurityAccessLevel.Edit,
				            true, false);

				return actions;
			}
		}

		#endregion

		protected void Page_Load(object sender, EventArgs e)
		{
			if (AJAX.IsInstalled())
			{
				AJAX.RegisterScriptManager();
			}
			if (!Page.IsPostBack)
			{
                string appPath = MetaPostServices.GetAppPath();
                if (string.IsNullOrEmpty(appPath)) appPath = "/";
				lblBlogProvider.Text = Localization.GetString("lblBlogProvider.Text") + Request.Url.Scheme.ToString() + "://" + PortalSettings.PortalAlias.HTTPAlias + 
				                        appPath + "metapost.ashx?key=" +
				                        MetaPostServices.GetFriendlyNameFromModuleDefinition("View_Blog");
				lblTextHtmlProvider.Text = Localization.GetString("lblTextHtmlProvider.Text") + Request.Url.Scheme.ToString() + "://" + PortalSettings.PortalAlias.HTTPAlias + 
										appPath + "metapost.ashx?key=" +
										MetaPostServices.GetFriendlyNameFromModuleDefinition("Text/HTML") + "&sid=nnn";
				lblAnnouncementsProvider.Text = Localization.GetString("lblAnnouncementsProvider.Text") + Request.Url.Scheme.ToString() + "://" + PortalSettings.PortalAlias.HTTPAlias + 
										appPath + "metapost.ashx?key=" +
										MetaPostServices.GetFriendlyNameFromModuleDefinition("Announcements");
				lblFAQsProvider.Text = Localization.GetString("lblFAQsProvider.Text") + Request.Url.Scheme.ToString() + "://" + PortalSettings.PortalAlias.HTTPAlias + 
										appPath + "metapost.ashx?key=" +
										MetaPostServices.GetFriendlyNameFromModuleDefinition("FAQs");
				lblHelpProvider.Text = Localization.GetString("lblHelpProvider.Text") + Request.Url.Scheme.ToString() + "://" + PortalSettings.PortalAlias.HTTPAlias + 
										appPath + "metapost.ashx?key=" +
										MetaPostServices.GetFriendlyNameFromModuleDefinition("Help");
				lblForumProvider.Text = Localization.GetString("lblForumProvider.Text") + Request.Url.Scheme.ToString() + "://" + PortalSettings.PortalAlias.HTTPAlias + 
										appPath + "metapost.ashx?key=" +
										MetaPostServices.GetFriendlyNameFromModuleDefinition("Forum");
			}

			lnkReturn.NavigateUrl = Globals.NavigateURL(TabId);
			ContainerControl.Visible = (UserInfo.IsSuperUser) ? true : false;
		}

		protected void cmdManagePortals_Click(object sender, EventArgs e)
		{
			Response.Redirect(Globals.NavigateURL(TabId, "ManagePortals", "mid=" + ModuleId));
		}

		protected void cmdManageImages_Click(object sender, EventArgs e)
		{
			Response.Redirect(Globals.NavigateURL(TabId, "ManageImages", "mid=" + ModuleId));
		}

		protected void cmdManageProviders_Click(object sender, EventArgs e)
		{
			Response.Redirect(Globals.NavigateURL(TabId, "ManageProviders", "mid=" + ModuleId));
		}
	}
}